package game;

import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;

public class HudPlayer extends Hud
{

	private static final long serialVersionUID = 1L;
	private Point sizeFundoOri = new Point(100, 100);
	private Point sizeSangueOri = new Point(97, 97);
	private Point sizeAbilidadeOri = new Point(44, 99);
	private Point2D posSangue = new Point2D.Double(0, 0);
	private Point2D posAbilidade = new Point2D.Double(0, 0);
	private Point sizeSangue = sizeSangueOri;
	
	public HudPlayer(int index, Point2D position, Point2D size) {
		super(index, new Point2D.Double(2, 2), size, new Rectangle(0, 0, 170, 170));
	}

	public void update(Player player)
	{
		super.updateMovimentoHudPlayer(player);
		
		sizeSangue = new Point((int)this.sizeSangue.getX(), 
				(int)(this.sizeSangueOri.getY()/(player.getHPMax()/player.getHP())));
		
		
		posSangue = new Point2D.Double((int)this.getPosition().getX() + 1, 
				((int)((this.getPosition().getY() + 2) + (this.sizeSangueOri.getY() - sizeSangue.getY()))));
		
		posAbilidade = new Point2D.Double(
				(this.getPosition().getX() + ((this.sizeFundoOri.getX())/2) - this.sizeAbilidadeOri.getX()/2),
				((this.getPosition().getY() + this.sizeFundoOri.getY()) - (this.sizeAbilidadeOri.getY()/2) - 3));
	}
	
	public void draw(Graphics g)
	{
		//FUNDO
		
		g.drawImage(getImage(),
				(int)this.getPosition().getX(),
				(int)this.getPosition().getY(),
				(int)(this.getPosition().getX() + this.sizeFundoOri.getX()),
				(int)(this.getPosition().getY() +this.sizeFundoOri.getY()),
				0,
				0,
				(int)this.sizeFundoOri.getX(),
				(int)this.sizeFundoOri.getY(),
				null);
		
		
		
		//SANGUE
		g.drawImage(getImage(),
				(int)this.posSangue.getX(),
				(int)this.posSangue.getY(),
				(int)(this.posSangue.getX() + sizeSangue.getX()),
				(int)(this.posSangue.getY() + sizeSangue.getY()),
				(int)100,
				(int)(this.sizeSangueOri.getY() - sizeSangue.getY()),
				(int)(100 + sizeSangue.getX()),
				(int)((this.sizeSangueOri.getY() - sizeSangue.getY()) + this.sizeSangue.getY()),
				null);
		
		//ABILIDADE
		g.drawImage(getImage(),
				(int)this.posAbilidade.getX(),
				(int)this.posAbilidade.getY(),
				(int)(this.posAbilidade.getX() + this.sizeAbilidadeOri.getX()),
				(int)(this.posAbilidade.getY() + this.sizeAbilidadeOri.getY()),
				197,
				0,
				(int)this.sizeAbilidadeOri.getX() + 197,
				(int)this.sizeAbilidadeOri.getY(),
				null);	
	}
}
